//
//  LYQActivityManageFooterCell.m
//  ZCProject
//
//  Created by Zheng on 2016/12/23.
//  Copyright © 2016年 Zheng. All rights reserved.
//

#import "LYQActivityManageFooterCell.h"

@implementation LYQActivityManageFooterCell

- (instancetype)initWithStyle:(LYQActivityManageFooterCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:UITableViewCellStyleDefault reuseIdentifier:reuseIdentifier];
    if (self) {
        
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        
        [self addSubviewsInContentViewWithStyle:style];
        
        [self layoutSubviewsInContentViewWithStyle:style];
        
    }
    return self;
}

#pragma mark - add subviews
- (void)addSubviewsInContentViewWithStyle:(LYQActivityManageFooterCellStyle)style {
    
    
    if (style == LYQActivityManageFooterCellStyleRelease) {
        [self.contentView addSubview:self.manageBtn];
    } else {
        [self.contentView addSubview:self.timeBtn];
        [self.contentView addSubview:self.locationBtn];
        [self.contentView addSubview:self.stateBtn];
    }
}

#pragma mark - layout subviews
- (void)layoutSubviewsInContentViewWithStyle:(LYQActivityManageFooterCellStyle)style {
    
    
    if (style == LYQActivityManageFooterCellStyleRelease) {
        
        [_manageBtn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.centerX.equalTo(self);
        }];
        
    } else {
        
        [_timeBtn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(kWScale(35));
            make.centerY.equalTo(self);
            make.width.equalTo(@(kWScale(100)));
        }];
        
        [_locationBtn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(_timeBtn.mas_right);
            make.centerY.equalTo(_timeBtn);
            make.width.equalTo(@(kWScale(100)));
        }];
        
        [_stateBtn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(_locationBtn.mas_right);
            make.centerY.equalTo(_timeBtn);
            make.width.equalTo(@(kWScale(100)));
        }];
    }
}

#pragma mark - lazy load subviews
- (UIButton *)manageBtn {
    if (_manageBtn) {
        return _manageBtn;
    }
    
    _manageBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [_manageBtn setTitle:@"报名管理" forState:UIControlStateNormal];
    [_manageBtn setTitleColor:kLYQBlue forState:UIControlStateNormal];
    _manageBtn.titleLabel.font = kWFont(15);
    
    return _manageBtn;
}

- (UIButton *)timeBtn {
    if (_timeBtn) {
        return _timeBtn;
    }
    
    _timeBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [_timeBtn setTitle:@"07/30 开始" forState:UIControlStateNormal];
    [_timeBtn setTitleColor:kHexadecimal(@"666666") forState:UIControlStateNormal];
    _timeBtn.titleLabel.font = kWFont(15);
    [_timeBtn setImage:[UIImage imageNamed:@"s_tcicon"] forState:UIControlStateNormal];
    [_timeBtn setTitleEdgeInsets:UIEdgeInsetsMake(0, kWScale(7), 0, 0)];
    _timeBtn.userInteractionEnabled = NO;

    return _timeBtn;
}

- (UIButton *)locationBtn {
    if (_locationBtn) {
        return _locationBtn;
    }
    
    _locationBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [_locationBtn setTitle:@"北京" forState:UIControlStateNormal];
    [_locationBtn setTitleColor:kHexadecimal(@"666666") forState:UIControlStateNormal];
    _locationBtn.titleLabel.font = kWFont(15);
    [_locationBtn setImage:[UIImage imageNamed:@"s_tcicon"] forState:UIControlStateNormal];
    [_locationBtn setTitleEdgeInsets:UIEdgeInsetsMake(0, kWScale(7), 0, 0)];
    _locationBtn.userInteractionEnabled = NO;
    
    return _locationBtn;
}

- (UIButton *)stateBtn {
    if (_stateBtn) {
        return _stateBtn;
    }
    
    _stateBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [_stateBtn setTitle:@"已报名" forState:UIControlStateNormal];
    [_stateBtn setTitleColor:kHexadecimal(@"666666") forState:UIControlStateNormal];
    _stateBtn.titleLabel.font = kWFont(15);
    [_stateBtn setImage:[UIImage imageNamed:@"s_tcicon"] forState:UIControlStateNormal];
    [_stateBtn setTitleEdgeInsets:UIEdgeInsetsMake(0, kWScale(7), 0, 0)];
    _stateBtn.userInteractionEnabled = NO;
    
    return _stateBtn;
}


@end
